import { formatCount, convertCurrency } from '@/utils/common.js';

function maintainViews(info) {
  return {
    css: {
      backgroundColor: '#FFFFFF',
      width: '702rpx',
      padding: '15rpx',
      boxSizing: "border-box",
      fontSize: '14rpx',
      'line-height': '17rpx'
    },
    views: [
       // 标题
       {
        type: 'view',
        css: {
          display: 'flex',
          justifyContent: 'center',
          alignItems: 'center',
          flexDirection: 'column',
          fontWeight: 'bold',
          textAlign: 'center',
          marginBottom: '24rpx',
          position: 'relative',
          width: '654rpx'
        },
        views: [
          {
            type: 'view',
            css: {
              height: '34rpx',
              display: 'flex',
              justifyContent: 'center',
              alignItems: 'center',
              position: 'relative',
              fontSize: '22rpx',
              marginTop: '10rpx'
            },
            views: [
              {
                type: 'text',
                text: info.repairShopName,
              }]
          },
          {
            type: 'view',
            css: {
              height: '6rpx',
              color: 'transparent',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
              borderTopWidth: '1rpx',
              'box-sizing': 'border-box',
              position: 'relative',
              fontSize: '22rpx',
            },
            views: [
              {
                type: 'text',
                text: info.repairShopName,
              }]
          },
          {
            type: 'view',
            css: {
              top: 0,
              left: 0,
              position: 'absolute',
            },
            views: [
              {
                type: 'image',
                src: info.extend.logo  ? (info.extend.logo += '?imageView2/2/h/84') : '',
                css: {
                  'flex-shrink': 0,
                  height: '56rpx',
                  // width: '56rpx',
                  marginLeft: '28rpx'
                }
              }
            ]
          }, {
            type: 'view',
            css: {
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'flex-end',
              top: '24rpx',
              right: 0,
              position: 'absolute',
              color: '#875A38'
            },
            views: [
              {
                type: 'text',
                text: info.number,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          }
        ]
      },
      // table
      {
        type: 'view',
        css: {
          border: '2rpx solid #333333',
          display: 'flex',
          alignItems: 'flex-start',
          justifyContent: 'space-between',
          'flex-wrap': 'wrap',
          marign: '4rpx 0 8rpx 0',
          'box-sizing': 'border-box',
        },
        views: [
          // 第一行
          {
            type: 'view',
            css: {
              width: '335rpx',
              display: 'flex',
              alignItems: 'center',
              'box-sizing': 'border-box',
              height: '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
              borderRightWidth: '1rpx',
            },
            views: [
              {
                type: 'text',
                text: '客户名称：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.customer.name,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          {
            type: 'view',
            css: {
              width: '335rpx',
              display: 'flex',
              alignItems: 'center',
              'box-sizing': 'border-box',
              height: '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
            },
            views: [
              {
                type: 'text',
                text: '客户电话：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.customer.phone,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          // 第二行
          {
            type: 'view',
            css: {
              width: '672rpx',
              display: 'flex',
              alignItems: 'center',
              'box-sizing': 'border-box',
              'min-height': '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
              padding: '2rpx 16rpx'
            },
            views: [
              {
                type: 'text',
                text: '客户地址：',
                css: {
                  "flex-shrink": 0,
                }
              },
              {
                type: 'text',
                text: info.address,
                css: {
                  fontWeight: 'bold',
                  paddingRight: '16rpx',
                  "line-height": '18rpx'
                }
              }
            ]
          },
          // 第三行
          {
            type: 'view',
            css: {
              width: '335rpx',
              display: 'flex',
              alignItems: 'center',
              height: '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
              borderRightWidth: '1rpx',
              'box-sizing': 'border-box',
            },
            views: [
              {
                type: 'text',
                text: '报修日期：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.repairTime,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          {
            type: 'view',
            css: {
              width: '335rpx',
              display: 'flex',
              alignItems: 'center',
              height: '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
              'box-sizing': 'border-box',
            },
            views: [
              {
                type: 'text',
                text: '报修人：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.faultRecord.reportPerson,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          // 第四行
          {
            type: 'view',
            css: {
              width: '672rpx',
              display: 'flex',
              alignItems: 'center',
              'box-sizing': 'border-box',
              height: '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
            },
            views: [
              {
                type: 'text',
                text: '设备名称及规格：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.faultRecord.category,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          // 第五行
          {
            type: 'view',
            css: {
              width: '672rpx',
              display: 'flex',
              alignItems: 'flex-start',
              'box-sizing': 'border-box',
              'min-height': '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
            },
            views: [
              {
                type: 'text',
                text: '故障现象：',
                css: {
                  padding: '8rpx 0 8rpx 16rpx',
                  "flex-shrink": 0
                }
              },
              {
                type: 'text',
                text: info.faultRecord.symptom,
                css: {
                  fontWeight: 'bold',
                  padding: '8rpx 16rpx 8rpx 0',
                  "line-height": '18rpx'
                }
              }
            ]
          },
          // 第六行
          {
            type: 'view',
            css: {
              width: '672rpx',
              display: 'flex',
              alignItems: 'flex-start',
              'box-sizing': 'border-box',
              'min-height': '34rpx',
              border: '0 solid #333333',
              borderBottomWidth: '1rpx',
            },
            views: [
              {
                type: 'text',
                text: '检修结论及处理方案：',
                css: {
                  padding: '8rpx 0 8rpx 16rpx'
                }
              },
              {
                type: 'text',
                text: info.faultRecord.repairResult,
                css: {
                  fontWeight: 'bold',
                  padding: '8rpx 16rpx 8rpx 0',
                  'line-height': '18rpx'
                }
              }
            ]
          },
          // 第七行
          {
            type: 'view',
            css: {
              width: '334rpx',
              display: 'flex',
              alignItems: 'center',
              height: '34rpx',
              border: '0 solid #333333',
              borderRightWidth: '1rpx',
              'box-sizing': 'border-box',
            },
            views: [
              {
                type: 'text',
                text: '维修费：',
                css: {
                  paddingLeft: '16rpx'
                }
              },
              {
                type: 'text',
                text: info.receivableAmount,
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          },
          {
            type: 'view',
            css: {
              width: '334rpx',
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'space-between',
              height: '34rpx',
              'box-sizing': 'border-box',
            },
            views: [
              {
                type: 'text',
                text: '验收日期：',
                css: {
                  paddingLeft: '16rpx',
                  "flex-shrink": 0
                }
              },
              {
                type: 'text',
                text: info.faultRecord.verifyTime || '',
                css: {
                  fontWeight: 'bold',
                  "flex-shrink": 0
                }
              },
              (info.extend.sealType == '1' || info.extend.sealType == '2') && info.extend.sealUrl ?
                {
                  type: 'view',
                  css: {
                    width: '40rpx',
                    height: '34rpx',
                    display: 'flex',
                    alignItems: 'center',
                    justifyContent: 'flex-end'
                  },
                  views: [
                    {
                      type: 'image',
                      src: info.extend.sealUrl,
                      css: {
                        'flex-shrink': 0,
                        height: '96rpx',
                      }
                    }
                  ]
                } : {},
            ]
          },
        ]
      },
      // bottom 行
      {
        type: 'view',
        css: {
          width: '100%',
          display: 'flex',
          alignItems: 'center',
          height: '34rpx',
          marginTop: '4rpx'
        },
        views: [
          {
            type: 'view',
            css: {
              width: '224rpx',
              display: 'flex',
              alignItems: 'center',
            },
            views: [
              {
                type: 'text',
                text: '应收金额：',
                css: {
                  'flex-shrink': 0,
                }
              },
              {
                type: 'text',
                text: '￥' + formatCount(info.receivableAmount),
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          }, {
            type: 'view',
            css: {
              width: '224rpx',
              display: 'flex',
              alignItems: 'center',
            },
            views: [
              {
                type: 'text',
                text: '实收金额：',
                css: {
                  'flex-shrink': 0,
                }
              },
              {
                type: 'text',
                text: '￥' + formatCount(info.actualAmount),
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          }, {
            type: 'view',
            css: {
              width: '224rpx',
              display: 'flex',
              alignItems: 'center',
            },
            views: [
              {
                type: 'text',
                text: '欠款金额：',
                css: {
                  'flex-shrink': 0,
                }
              },
              {
                type: 'text',
                text: '￥' + formatCount(Math.max(Number(info.receivableAmount) - Number(info.actualAmount), 0)),
                css: {
                  fontWeight: 'bold'
                }
              }
            ]
          }
        ]
      },
      {
        type: 'view',
        css: {
          width: '100%',
          display: 'flex',
          alignItems: 'flex-start',
          height: '34rpx',
          marginTop: '4rpx'
        },
        views: [
          {
            type: 'view',
            css: {
              width: '224rpx',
              display: 'flex',
              alignItems: 'flex-start',
            },
            views: [
              {
                type: 'text',
                text: '开票人：',
                css: {
                  'flex-shrink': 0,
                }
              },
              info.extend.sealUrl && info.extend.sealType == '4' ?
                {
                  type: 'image',
                  src: info.extend.sealUrl,
                  css: {
                    'flex-shrink': 0,
                    height: '28rpx',
                  }
                } : {}
            ]
          }, info.extend.customerSignSwitch ? {
            type: 'view',
            css: {
              width: '224rpx',
              display: 'flex',
              alignItems: 'flex-start',
            },
            views: [
              {
                type: 'text',
                text: '客户签名：',
                css: {
                  'flex-shrink': 0,
                }
              },
              {
                type: 'image',
                src: info.extend.customerSign += '?imageView2/2/h/40',
                css: {
                  height: '24rpx',
                }
              }
            ]
          } : {
          }
        ]
      },
    ]
  }
}
export default maintainViews